<?php

namespace App\Models\User;

use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Model;

class BecomeDueModel extends BaseModel
{
    protected $table = 'become_due';

    protected $fillable = [
        'user_id',
        'name',
        'price',
        'cycle',
        'svg',
        'renew',
        'start_at',
        'end_at',
        'remind_days',
        'status',
        'remark',
        'created_at',
        'updated_at',
    ];

    const CYCLE_DEFAULT = 0;
    const CYCLE_DAY     = 1;
    const CYCLE_WEEK    = 2;
    const CYCLE_MONTH   = 3;
    const CYCLE_YEAR    = 4;
    const CYCLES        = [
        self::CYCLE_DEFAULT => '',
        self::CYCLE_DAY     => '天',
        self::CYCLE_WEEK    => '周',
        self::CYCLE_MONTH   => '月',
        self::CYCLE_YEAR    => '年',
    ];

    const RENEW_OFF = 0;
    const RENEW_ON  = 1;
    const RENEWS    = [
        self::RENEW_OFF => '',
        self::RENEW_ON  => '自动续订',
    ];

    const STATUS_EXPIRED  = 0;
    const STATUS_NORMAL   = 1;
    const STATUS_DISABLED = 2;
    const STATUSES        = [
        self::STATUS_EXPIRED  => '已过期',
        self::STATUS_NORMAL   => '正常',
        self::STATUS_DISABLED => '已停用',
    ];

    /**
     * 周期文本访问器
     */
    public function getCycleTextAttribute()
    {
        return self::CYCLES[$this->cycle] ?? '';
    }

    /**
     * 续订文本访问器
     */
    public function getRenewTextAttribute()
    {
        return self::RENEWS[$this->renew] ?? '';
    }

    /**
     * 状态文本访问器
     */
    public function getStatusTextAttribute()
    {
        return self::STATUSES[$this->status] ?? '';
    }


}
